package com.hxgz.steel.controller.backend;

import com.github.pagehelper.PageInfo;
import com.google.common.collect.Maps;
import com.hxgz.steel.common.ServerResponse;
import com.hxgz.steel.domain.Page;
import com.hxgz.steel.dto.OrderDetailDto;
import com.hxgz.steel.dto.OrderTimeDto;
import com.hxgz.steel.service.BackendOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "订单管理", description = "后台:订单管理")
@RestController
@RequestMapping("BackendOrder")
public class BackendOrderController {

  @Autowired
  BackendOrderService backendOrderService;

  @ApiOperation(value = "订单管理列表查询")
  @RequestMapping(value = "checkOrderList.do", method = RequestMethod.POST)
  public ServerResponse<PageInfo<OrderTimeDto>> checkOrderList(
      @ApiParam("1 自营订单,0第三方订单") @RequestParam(required = true) Integer orderStates,
      @ApiParam("下单开始时间") @RequestParam(required = false) String startDate,
      @ApiParam("下单结束时间") @RequestParam(required = false) String endDate,
      @ApiParam("订单编号") @RequestParam(required = false) String orderNo,
      @ApiParam("买家名称") @RequestParam(required = false) String realName,
      @ApiParam("是否仓储加工  0否 1是") @RequestParam(required = false) Integer processStatus,
      @ApiParam("是否现货商家 0否 1是") @RequestParam(required = false) Integer spotGoodsStatus,
      @ApiParam("订单发送状态 0待付款 1 待发货 2已发货 3已完成 4已取消 5已关闭") @RequestParam(required = false) Integer gooodsStatus,
      @ApiParam("商铺名称") @RequestParam(required = false) String merchantName,
      Page page) {
    HashMap<Object, Object> map = Maps.newHashMap();
    map.put("orderStatus", orderStates);
    map.put("startDate", startDate);
    map.put("endDate", endDate);
    map.put("orderNo", orderNo);
    map.put("realName", realName);
    map.put("processStatus", processStatus);
    map.put("spotGoodsStatus", spotGoodsStatus);
    map.put("goodsStatus", gooodsStatus);
    map.put("merchantName", merchantName);
    return backendOrderService.checkOrderList(map, page);
  }

  @ApiOperation("订单管理订单详情查询")
  @RequestMapping(value = "checkOrderListById.do", method = RequestMethod.POST)
  public ServerResponse<OrderDetailDto> checkOrderListById(@RequestParam String id) {
    return backendOrderService.checkOrderListById(id);
  }


}
